<%@ page language="java" import="java.util.*,java.sql.*,java.util.Date,java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!-- 
功能介绍：添加DAO

 -->
<%@ include file="/files/db/conn.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<%
PreparedStatement psm = null;
try {
	psm = conn.prepareStatement("insert into t_department (departmentname) values(?)");
	psm.setString(1, request.getParameter("departmentname")!=null?request.getParameter("departmentname"):"");
	psm.executeUpdate();
	
	response.sendRedirect("list.jsp?flag=success");

} catch (Exception e) {
	out.print(e.getMessage());
} finally {
	if (stmt != null) {
		try {
			stmt.close();
		} catch (Exception e) {
	e.printStackTrace();
		}
	}
	if (psm != null) {
		try {
	psm.close();
		} catch (Exception e) {
	e.printStackTrace();
		}
	}
	if (conn != null) {
		try {
	conn.close();
		} catch (Exception e) {
	e.printStackTrace();
		}
	}
}
%>
</body>
</html>
